/* @(#)GSLoginAction.java    
*
* Project: BUS
*
* Modify Information:
* =============================================================================
*   Author       Date       Description
*   ------------ ---------- ---------------------------------------------------
*   Simonyi Peng 2006-2-7    建立
*
* Copyright Notice:
* =============================================================================
*    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
*        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
*        Haidian District, Beijing ,100081, China All rights reserved.
*
*    This software is the confidential and proprietary information of
*        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
*        You shall not disclose such Confidential Information and shall use it
*        only in accordance with the terms of the license agreement you entered
*        into with HiTRUST.
*
* Warning:
* =============================================================================
* 
*/
package com.hitrust.gs.action;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;

import system.LoginContext;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.GSBusOrderProcesser;
import com.hitrust.gs.business.GSBusOrgProcessor;
import com.hitrust.gs.business.GSManufactureProcessor;
import com.hitrust.gs.business.GSOrderProcesser;
import com.hitrust.gs.form.GSOrderAuthorizeSaveForm;
import com.hitrust.gs.form.GSOrderModifySaveForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.vo.GSOrderAuthorizeSaveVO;
import com.hitrust.gs.vo.GSOrderModifySaveVO;

/**
 * @author simonyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GSOrderModifySaveAction extends GSBaseAction {
	public String execute(GSBaseForm aForm) throws Exception {
	    
	    LoginContext context = (LoginContext)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
        
        GSOrderModifySaveForm tForm = (GSOrderModifySaveForm)aForm;
        String[] detailCheckbox = tForm.getIndexs();
        String[] detailId = tForm.getOrderdetailid();
        String[] orderId = tForm.getOrderid();
        String[] orderCount = tForm.getOrdercount();
        String[] concentricityId = tForm.getConcentricityid();
        String[] concentricityId_ = tForm.getConcentricityid_();
        String[] deliverDate = tForm.getDeliverdate();
        String[] deliverTime = tForm.getDelivertime();
        String[] manufactureId = tForm.getManufactureid();
        String[] mode=tForm.getMode();
        // add by Jackey start
        
        //增加对定单状态的保存       
        String[] orderDetailStatus = tForm.getOrderDetailStatus();
        
        // add by Jackye end

        ArrayList list = new ArrayList();
        for(int i=0;i<detailCheckbox.length;i++){
            for(int j=0;j<detailId.length;j++){
                if(detailId[j].equals(detailCheckbox[i])){
                    GSOrderModifySaveVO vo = new GSOrderModifySaveVO ();
                    vo.orderDetailId = detailId[j];
                    vo.orderId = orderId[j];
                    vo.orderCount = orderCount[j];
                    vo.concentricityId = concentricityId[j];
                    vo.concentricityId_old = concentricityId_[j];
                    vo.deliverGoodsDate = deliverDate[j];
                    vo.deliverGoodsTime = deliverTime[j];
                    vo.manufactureId = manufactureId[j];
					
					// add by Jackey start
					vo.orderDetailStatus = orderDetailStatus[j];
					// add by Jackey end
					vo.mode=mode[j];
                    list.add(vo);
                }
            }
        }

        
        GSOrderProcesser oproc = new GSOrderProcesser();
        try{

            oproc.modifyOrder(context,list);
            
	        //返回到qryaction时，给出是否重新查询的指示
	        aForm.getRequest().setAttribute("ISQUERYCONDITIONEXIST","T");
	        aForm.getRequest().setAttribute("SUCCESSMSG","申购单明细信息修改成功");

        }catch(GSException e){
            aForm.getRequest().setAttribute("action", "A150201.do");
            throw e;
        }
        
        return GSBaseConstants.FORWARD_SUCCESS;
        
	}
}
